package com.example.common.mvi

import android.os.Bundle
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.example.common.base.BaseActivity
import kotlinx.coroutines.launch

abstract class BaseMviActivity<T:ViewDataBinding>:BaseActivity<T> (){

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initData()
        updateUi()
    }

    private fun updateUi() {
       lifecycleScope.launch {
           lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED){
               collectUiState()
           }
       }
    }

    open suspend fun collectUiState() {

    }

    private fun initData() {
        lifecycleScope.launch {
            sendViewIntent()
        }
    }

    open suspend fun sendViewIntent() {

    }





}